{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<Hds::SegmentedGroup ...attributes as |S|>
  <S.Dropdown @listPosition="bottom-left" @height="200px" as |dd|>
    <dd.ToggleButton data-test-toggle-month @text={{or this.selectedMonth.name "Month"}} @color="secondary" />
    {{#each this.dropdownMonths as |month|}}
      <dd.Interactive
        data-test-dropdown-month={{month.name}}
        disabled={{if (gt month.index this.maxMonthIdx) true false}}
        {{on "click" (fn this.selectMonth month dd)}}
        @text={{month.name}}
      />
    {{/each}}
  </S.Dropdown>
  <S.Dropdown data-test-year-list @listPosition="bottom-left" @height="200px" as |dd|>
    <dd.ToggleButton data-test-toggle-year @text={{or this.selectedYear "Year"}} @color="secondary" />
    {{#each this.dropdownYears as |year|}}
      <dd.Interactive
        data-test-dropdown-year={{year}}
        disabled={{if (eq year this.disabledYear) true false}}
        {{on "click" (fn this.selectYear year dd)}}
        @text={{year}}
      />
    {{/each}}
  </S.Dropdown>
  <S.Button
    data-test-date-dropdown-submit
    disabled={{if (and this.selectedMonth this.selectedYear) false true}}
    {{on "click" this.handleSubmit}}
    @text={{or @submitText "Submit"}}
  />
</Hds::SegmentedGroup>
{{#if this.invalidDate}}
  <AlertInline @type="danger" @message={{this.invalidDate}} class="has-top-padding-s" />
{{/if}}